package com.ruoyi.system.api;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
import com.ruoyi.system.api.model.LoginUser;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户服务
 * 
 * @author ruoyi
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")

    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/getInfoByid")
    public R<SysUser> getUserinfoById(@RequestBody Long UId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/editPassword")
    public R<Boolean> alterPassword(@RequestParam("username") String username,@RequestParam("password") String password,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
    *@Description: 获取可聊天的用户列表
    *@Author: lilirui
    *@Date: 2023-04-14
     * @return
    */

    @GetMapping("/user/getchaterlist")
    public R<List<SysUser>> getuserlist(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/getuserlistByIds")
    public R<List<SysUser>> getuserlistByIds(@RequestParam("hisList") ArrayList<Long> hisList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PutMapping("/updateInfo")
    public AjaxResult updateInfo(@RequestBody SysUser user);
}
